package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SysCompanyUserControllerApi;
import com.nineclock.system.dto.SysCompanyUserDTO;
import com.nineclock.system.service.SysCompanyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@RestController
@RequestMapping("/companyUser")
public class SysCompanyUserController implements SysCompanyUserControllerApi {

    @Autowired
    SysCompanyUserService companyUserService;

    @Override
    @GetMapping("/queryone")
    public Result<SysCompanyUserDTO> findCompanyUserByMobile(String mobile) {
        SysCompanyUserDTO companyUserDTO = companyUserService.queryOne(mobile);
        return Result.success(companyUserDTO);
    }

    @Override
    @GetMapping("/query")
    public Result<List<SysCompanyUserDTO>> queryCompanyUser(Long companyId, Long userId) {
        List<SysCompanyUserDTO> companyUserDTOList = companyUserService.queryCompanyUser(companyId, userId);
        return Result.success(companyUserDTOList);
    }
}
